package com.liaoxuefeng.java_thread;

public class TestThread {

    public static void main(String[] args) {

       /* // 创建一线程
        Thread t = new Thread();
        t.start();

        // 自己的线程类
        Thread mt = new MyThread();
        mt.start();

        // Runnable 实例
        Thread t2 = new Thread(new MyRunnable());
        t2.start();

        // lambda语法创建
        Thread t3 = new Thread(() -> {
            System.out.println("lambda start new thread!");
        });
        t3.start();*/

        System.out.println("main starting,,");
        Thread t4 = new Thread() {
            public void run() {
                System.out.println("thread run...");
                // 暂停一会看效果
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("thread end...");
            }
        };
        t4.start();
        System.out.println("main end .....");
    }
}

class MyRunnable implements Runnable {
    @Override
    public void run() {
        System.out.println("MyRunnable start new thread");
    }
}

class MyThread extends Thread {
    @Override
    public void run() {
        System.out.println("MyThread start new thread");
    }
}